/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ez2find.manager;

import com.ez2find.model.CategoriaInmobiliario;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Owner
 */
@Stateless
public class HousCategorieManagerBean implements HousCategorieManagerLocal {
    
    @PersistenceContext
    private EntityManager em;
    
    public void create(CategoriaInmobiliario housCategorie)throws Exception {
        em.persist(housCategorie);
    }
 
    public void update(CategoriaInmobiliario housCategorie)throws Exception {
        em.merge(housCategorie);
    }
    
    public void delete(CategoriaInmobiliario housCategorie)throws Exception {
        housCategorie=em.merge(housCategorie);
        em.remove(housCategorie);
    }
    
    public CategoriaInmobiliario find(long id){
        return em.find(CategoriaInmobiliario.class,id);
    }

    public List<CategoriaInmobiliario> listAll(){
        Query query=em.createNamedQuery("listAllHousCategories");
        List<CategoriaInmobiliario> result=query.getResultList();
        return result;
    }
    
}
